<template>
	<view class="pages">
		<my-header bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">登录</block>
		</my-header>
		<view class="wrap col">
			<view class="tips">为了更好地提供服务，将会获取您的头像，昵称，性别，地区等基本信息</view>
			<view class="login row bg-cyan">
				<button class="button" @getuserinfo="login" lang="zh_CN"  open-type="getUserInfo"></button>
				登录
			</view>
			<!-- <button class="action" open-type="contact">登录aaaa</button>
			<button class="action" open-type="openSetting">授权</button> -->
			<!-- <rich-text :nodes="content"></rich-text> -->
		</view>
		
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				content:""
			}
		},
		onLoad() {
		
		},
		methods: {
			async login(e){
				let openid= await wx.$get_openId()
				let user_info={
					...e.detail.userInfo,
					openid
				}
				const res=await uni.$request({
					...user_info
				},"api/user/login")
				if (res.code==200) {
					uni.setStorageSync("user_info", user_info)
					uni.setStorageSync("token", res.data.token)
					uni.navigateBack({
						 delta: 1
					});
				}
			}
		}
	}
</script>

<style lang="scss">
	@import "./login";
	.tips{
        width: 500rpx;
		text-align: center;
		margin-bottom: 100rpx;
    }
</style>